const { ccclass, property, executeInEditMode } = cc._decorator;

@ccclass
@executeInEditMode
export default class TransparentGradient extends cc.Component {

    @property
    upColor: cc.Color = cc.Color.WHITE;
    @property
    downColor: cc.Color = cc.Color.WHITE;

    @property
    set refresh(val: boolean) {
        this.updateProperties();
    }
    get refresh() { return false; }

    _mat: cc.Material = null;

    onLoad() {
        let comp = this.node.getComponent(cc.Sprite) || this.node.getComponent(cc.Label);
        this._mat = comp.getMaterial(0);
        this.updateProperties();
    }

    start() {

    }

    updateProperties() {
        this._mat.setProperty("upColor", this.upColor);
        this._mat.setProperty("downColor", this.downColor);
    }
}
